<!DOCTYPE html>
<html lang=en>
<head>
    <!-- so meta -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="HandheldFriendly" content="True">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
    <meta name="description" content="spring cloud+.net core搭建微服务架构：服务注册（一）背景公司去年开始使用dotnet core开发项目。公司的总体架构采用的是微服务，那时候由于对微服务的理解并不是太深，加上各种组件的不成熟，只是把项目的各个功能通过业务层面拆分，然后通过nginx代理，项目最终上线。但是这远远没达到微服务的要求，其中服务治理，断路器都没有。我个人理解，我们谈微服务实际上更多的是谈服务治理这块">
<meta property="og:type" content="article">
<meta property="og:title" content="springcloud+steeltoe实现微服务架构：服务注册（一）">
<meta property="og:url" content="http://yoursite.com/2018/11/04/springcloud+steeltoe%E5%AE%9E%E7%8E%B0%E5%BE%AE%E6%9C%8D%E5%8A%A1%E6%9E%B6%E6%9E%84%EF%BC%9A%E6%9C%8D%E5%8A%A1%E6%B3%A8%E5%86%8C%EF%BC%88%E4%B8%80%EF%BC%89/index.html">
<meta property="og:site_name" content="TmoonSite">
<meta property="og:description" content="spring cloud+.net core搭建微服务架构：服务注册（一）背景公司去年开始使用dotnet core开发项目。公司的总体架构采用的是微服务，那时候由于对微服务的理解并不是太深，加上各种组件的不成熟，只是把项目的各个功能通过业务层面拆分，然后通过nginx代理，项目最终上线。但是这远远没达到微服务的要求，其中服务治理，断路器都没有。我个人理解，我们谈微服务实际上更多的是谈服务治理这块">
<meta property="og:locale" content="en_US">
<meta property="og:image" content="https://images.cnblogs.com/cnblogs_com/longxianghui/1083293/o_eureka.png">
<meta property="og:image" content="https://images.cnblogs.com/cnblogs_com/longxianghui/1083293/o_eureka1.png">
<meta property="og:image" content="https://images.cnblogs.com/cnblogs_com/longxianghui/1083293/o_eureka2.png">
<meta property="article:published_time" content="2018-11-04T11:58:48.000Z">
<meta property="article:modified_time" content="2020-01-07T10:48:14.756Z">
<meta property="article:author" content="Tmoonlight">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://images.cnblogs.com/cnblogs_com/longxianghui/1083293/o_eureka.png">
    
    
        
          
              <link rel="shortcut icon" href="/images/favicon.ico">
          
        
        
          
            <link rel="icon" type="image/png" href="/images/logo2.gif" sizes="192x192">
          
        
        
          
            <link rel="apple-touch-icon" sizes="180x180" href="/images/logo2.gif">
          
        
    
    <!-- title -->
    <title>springcloud+steeltoe实现微服务架构：服务注册（一）</title>
    <!-- styles -->
    
<link rel="stylesheet" href="/css/style.css">

    <!-- persian styles -->
    
      
<link rel="stylesheet" href="/css/rtl.css">

    
    <!-- rss -->
    
    
<meta name="generator" content="Hexo 4.2.0"></head>

<body class="max-width mx-auto px3 ltr">
    
      <div id="header-post">
  <a id="menu-icon" href="#"><i class="fas fa-bars fa-lg"></i></a>
  <a id="menu-icon-tablet" href="#"><i class="fas fa-bars fa-lg"></i></a>
  <a id="top-icon-tablet" href="#" onclick="$('html, body').animate({ scrollTop: 0 }, 'fast');" style="display:none;"><i class="fas fa-chevron-up fa-lg"></i></a>
  <span id="menu">
    <span id="nav">
      <ul>
         
          <li><a href="/">Home</a></li>
         
          <li><a href="/about/">About</a></li>
         
          <li><a href="/archives/">Writing</a></li>
         
          <li><a href="/projects_url">Projects</a></li>
        
      </ul>
    </span>
    <br/>
    <span id="actions">
      <ul>
        
        <li><a class="icon" href="/2018/11/06/NETCore%E6%BA%90%E7%A0%81%E5%AF%BC%E8%88%AA%EF%BC%88%E6%8C%89%E7%A8%8B%E5%BA%8F%E9%9B%86%E9%93%BE%E6%8E%A5%EF%BC%89/"><i class="fas fa-chevron-left" aria-hidden="true" onmouseover="$('#i-prev').toggle();" onmouseout="$('#i-prev').toggle();"></i></a></li>
        
        
        <li><a class="icon" href="/2018/10/27/excel%E9%A1%B9%E7%9B%AE/"><i class="fas fa-chevron-right" aria-hidden="true" onmouseover="$('#i-next').toggle();" onmouseout="$('#i-next').toggle();"></i></a></li>
        
        <li><a class="icon" href="#" onclick="$('html, body').animate({ scrollTop: 0 }, 'fast');"><i class="fas fa-chevron-up" aria-hidden="true" onmouseover="$('#i-top').toggle();" onmouseout="$('#i-top').toggle();"></i></a></li>
        <li><a class="icon" href="#"><i class="fas fa-share-alt" aria-hidden="true" onmouseover="$('#i-share').toggle();" onmouseout="$('#i-share').toggle();" onclick="$('#share').toggle();return false;"></i></a></li>
      </ul>
      <span id="i-prev" class="info" style="display:none;">Previous post</span>
      <span id="i-next" class="info" style="display:none;">Next post</span>
      <span id="i-top" class="info" style="display:none;">Back to top</span>
      <span id="i-share" class="info" style="display:none;">Share post</span>
    </span>
    <br/>
    <div id="share" style="display: none">
      <ul>
  <li><a class="icon" href="http://www.facebook.com/sharer.php?u=http://yoursite.com/2018/11/04/springcloud+steeltoe%E5%AE%9E%E7%8E%B0%E5%BE%AE%E6%9C%8D%E5%8A%A1%E6%9E%B6%E6%9E%84%EF%BC%9A%E6%9C%8D%E5%8A%A1%E6%B3%A8%E5%86%8C%EF%BC%88%E4%B8%80%EF%BC%89/" target="_blank" rel="noopener"><i class="fab fa-facebook " aria-hidden="true"></i></a></li>
  <li><a class="icon" href="https://twitter.com/share?url=http://yoursite.com/2018/11/04/springcloud+steeltoe%E5%AE%9E%E7%8E%B0%E5%BE%AE%E6%9C%8D%E5%8A%A1%E6%9E%B6%E6%9E%84%EF%BC%9A%E6%9C%8D%E5%8A%A1%E6%B3%A8%E5%86%8C%EF%BC%88%E4%B8%80%EF%BC%89/&text=springcloud+steeltoe实现微服务架构：服务注册（一）" target="_blank" rel="noopener"><i class="fab fa-twitter " aria-hidden="true"></i></a></li>
  <li><a class="icon" href="http://www.linkedin.com/shareArticle?url=http://yoursite.com/2018/11/04/springcloud+steeltoe%E5%AE%9E%E7%8E%B0%E5%BE%AE%E6%9C%8D%E5%8A%A1%E6%9E%B6%E6%9E%84%EF%BC%9A%E6%9C%8D%E5%8A%A1%E6%B3%A8%E5%86%8C%EF%BC%88%E4%B8%80%EF%BC%89/&title=springcloud+steeltoe实现微服务架构：服务注册（一）" target="_blank" rel="noopener"><i class="fab fa-linkedin " aria-hidden="true"></i></a></li>
  <li><a class="icon" href="https://pinterest.com/pin/create/bookmarklet/?url=http://yoursite.com/2018/11/04/springcloud+steeltoe%E5%AE%9E%E7%8E%B0%E5%BE%AE%E6%9C%8D%E5%8A%A1%E6%9E%B6%E6%9E%84%EF%BC%9A%E6%9C%8D%E5%8A%A1%E6%B3%A8%E5%86%8C%EF%BC%88%E4%B8%80%EF%BC%89/&is_video=false&description=springcloud+steeltoe实现微服务架构：服务注册（一）" target="_blank" rel="noopener"><i class="fab fa-pinterest " aria-hidden="true"></i></a></li>
  <li><a class="icon" href="mailto:?subject=springcloud+steeltoe实现微服务架构：服务注册（一）&body=Check out this article: http://yoursite.com/2018/11/04/springcloud+steeltoe%E5%AE%9E%E7%8E%B0%E5%BE%AE%E6%9C%8D%E5%8A%A1%E6%9E%B6%E6%9E%84%EF%BC%9A%E6%9C%8D%E5%8A%A1%E6%B3%A8%E5%86%8C%EF%BC%88%E4%B8%80%EF%BC%89/"><i class="fas fa-envelope " aria-hidden="true"></i></a></li>
  <li><a class="icon" href="https://getpocket.com/save?url=http://yoursite.com/2018/11/04/springcloud+steeltoe%E5%AE%9E%E7%8E%B0%E5%BE%AE%E6%9C%8D%E5%8A%A1%E6%9E%B6%E6%9E%84%EF%BC%9A%E6%9C%8D%E5%8A%A1%E6%B3%A8%E5%86%8C%EF%BC%88%E4%B8%80%EF%BC%89/&title=springcloud+steeltoe实现微服务架构：服务注册（一）" target="_blank" rel="noopener"><i class="fab fa-get-pocket " aria-hidden="true"></i></a></li>
  <li><a class="icon" href="http://reddit.com/submit?url=http://yoursite.com/2018/11/04/springcloud+steeltoe%E5%AE%9E%E7%8E%B0%E5%BE%AE%E6%9C%8D%E5%8A%A1%E6%9E%B6%E6%9E%84%EF%BC%9A%E6%9C%8D%E5%8A%A1%E6%B3%A8%E5%86%8C%EF%BC%88%E4%B8%80%EF%BC%89/&title=springcloud+steeltoe实现微服务架构：服务注册（一）" target="_blank" rel="noopener"><i class="fab fa-reddit " aria-hidden="true"></i></a></li>
  <li><a class="icon" href="http://www.stumbleupon.com/submit?url=http://yoursite.com/2018/11/04/springcloud+steeltoe%E5%AE%9E%E7%8E%B0%E5%BE%AE%E6%9C%8D%E5%8A%A1%E6%9E%B6%E6%9E%84%EF%BC%9A%E6%9C%8D%E5%8A%A1%E6%B3%A8%E5%86%8C%EF%BC%88%E4%B8%80%EF%BC%89/&title=springcloud+steeltoe实现微服务架构：服务注册（一）" target="_blank" rel="noopener"><i class="fab fa-stumbleupon " aria-hidden="true"></i></a></li>
  <li><a class="icon" href="http://digg.com/submit?url=http://yoursite.com/2018/11/04/springcloud+steeltoe%E5%AE%9E%E7%8E%B0%E5%BE%AE%E6%9C%8D%E5%8A%A1%E6%9E%B6%E6%9E%84%EF%BC%9A%E6%9C%8D%E5%8A%A1%E6%B3%A8%E5%86%8C%EF%BC%88%E4%B8%80%EF%BC%89/&title=springcloud+steeltoe实现微服务架构：服务注册（一）" target="_blank" rel="noopener"><i class="fab fa-digg " aria-hidden="true"></i></a></li>
  <li><a class="icon" href="http://www.tumblr.com/share/link?url=http://yoursite.com/2018/11/04/springcloud+steeltoe%E5%AE%9E%E7%8E%B0%E5%BE%AE%E6%9C%8D%E5%8A%A1%E6%9E%B6%E6%9E%84%EF%BC%9A%E6%9C%8D%E5%8A%A1%E6%B3%A8%E5%86%8C%EF%BC%88%E4%B8%80%EF%BC%89/&name=springcloud+steeltoe实现微服务架构：服务注册（一）&description=" target="_blank" rel="noopener"><i class="fab fa-tumblr " aria-hidden="true"></i></a></li>
  <li><a class="icon" href="https://news.ycombinator.com/submitlink?u=http://yoursite.com/2018/11/04/springcloud+steeltoe%E5%AE%9E%E7%8E%B0%E5%BE%AE%E6%9C%8D%E5%8A%A1%E6%9E%B6%E6%9E%84%EF%BC%9A%E6%9C%8D%E5%8A%A1%E6%B3%A8%E5%86%8C%EF%BC%88%E4%B8%80%EF%BC%89/&t=springcloud+steeltoe实现微服务架构：服务注册（一）" target="_blank" rel="noopener"><i class="fab fa-hacker-news " aria-hidden="true"></i></a></li>
</ul>

    </div>
    <div id="toc">
      <ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#spring-cloud-net-core搭建微服务架构：服务注册（一）"><span class="toc-number">1.</span> <span class="toc-text">spring cloud+.net core搭建微服务架构：服务注册（一）</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#背景"><span class="toc-number">2.</span> <span class="toc-text">背景</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#spring-cloud"><span class="toc-number">3.</span> <span class="toc-text">spring cloud</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#服务治理"><span class="toc-number">4.</span> <span class="toc-text">服务治理</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#搭建服务治理平台"><span class="toc-number">5.</span> <span class="toc-text">搭建服务治理平台</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#注册服务"><span class="toc-number">6.</span> <span class="toc-text">注册服务</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#后记"><span class="toc-number">7.</span> <span class="toc-text">后记</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#示例代码"><span class="toc-number">8.</span> <span class="toc-text">示例代码</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#传送门"><span class="toc-number">9.</span> <span class="toc-text">传送门</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#参考资料"><span class="toc-number">10.</span> <span class="toc-text">参考资料</span></a></li></ol>
    </div>
  </span>
</div>

    
    <div class="content index py4">
        
        <article class="post" itemscope itemtype="http://schema.org/BlogPosting">
  <header>
    
    <h1 class="posttitle" itemprop="name headline">
        springcloud+steeltoe实现微服务架构：服务注册（一）
    </h1>



    <div class="meta">
      <span class="author" itemprop="author" itemscope itemtype="http://schema.org/Person">
        <span itemprop="name">TmoonSite</span>
      </span>
      
    <div class="postdate">
      
        <time datetime="2018-11-04T11:58:48.000Z" itemprop="datePublished">2018-11-04</time>
        
      
    </div>


      

      

    </div>
  </header>
  

  <div class="content" itemprop="articleBody">
    <h1 id="spring-cloud-net-core搭建微服务架构：服务注册（一）"><a href="#spring-cloud-net-core搭建微服务架构：服务注册（一）" class="headerlink" title="spring cloud+.net core搭建微服务架构：服务注册（一）"></a><a href="https://www.cnblogs.com/longxianghui/p/7561259.html" target="_blank" rel="noopener">spring cloud+.net core搭建微服务架构：服务注册（一）</a></h1><h1 id="背景"><a href="#背景" class="headerlink" title="背景"></a>背景</h1><p>公司去年开始使用dotnet core开发项目。公司的总体架构采用的是微服务，那时候由于对微服务的理解并不是太深，加上各种组件的不成熟，只是把项目的各个功能通过业务层面拆分，然后通过nginx代理，项目最终上线。但是这远远没达到微服务的要求，其中服务治理，断路器都没有。我个人理解，我们谈微服务实际上更多的是谈服务治理这块东西，至于各个的服务只是微服务中的应用而已。一次偶然的机会发现了java的spring cloud这套框架，而且支持dotnet core集成（Steeltoe OSS）。所以目前我们的项目架构是spring cloud搭建底层微服务框架，dotnet core来编写业务逻辑。</p>
<h1 id="spring-cloud"><a href="#spring-cloud" class="headerlink" title="spring cloud"></a>spring cloud</h1><p>spring cloud是java平台提供的一套解决方案，目前市面上来说可能不是最好的微服务解决方案，但是一定是功能最齐全最全的解决方案。提供了一些微服务的基础功能，包括服务治理、负载均衡、断路器、配置中心、API网关等等。</p>
<h1 id="服务治理"><a href="#服务治理" class="headerlink" title="服务治理"></a>服务治理</h1><p>关于服务治理这块东西，网上太多太多的资料和原理。相信大家也看了很多，但是如何应用到实际的项目场景，为什么要这样做呢？传统的项目，服务与服务之间的调用都是通过URL来访问，如果是集群那么通过一个负载均衡地址来访问，增加或者减少机器都是通过维护负载均衡列表的IP地址来实现。微服务架构下，分散成了N个服务，每个服务又是一个集群，对于一个大项目来说，维护这些配置是非常头疼的。笔者曾经在某知名互联网公司工作过，公司最累最背锅的就是运维团队，基本24小时都在应付各个团队的部署上线工作以及各种配置的维护，而且还经常出错挨骂。那么服务治理就出现在这种应用场景之中，运维工程师不用再维护各个负载均衡节点，由服务中心去统一处理。举个简单例子，一个电商网站，分解成N个服务，其中有一个用户服务，有一个订单服务，用户服务需要调用订单服务，而订单服务是一个集群，对于用户中心来说他只需要知道访问订单中心即可，至于具体访问订单中心的哪台机器由服务中心来调配。</p>
<h1 id="搭建服务治理平台"><a href="#搭建服务治理平台" class="headerlink" title="搭建服务治理平台"></a>搭建服务治理平台</h1><ol>
<li><p>java开发环境和IDE使用请自行百度，笔者java开发的ide使用的intellij idea。</p>
</li>
<li><p>创建一个spring boot项目，项目名称service-center，添加spring cloud的依赖</p>
</li>
</ol>
<dependency>

<p><groupId>org.springframework.cloud</groupId></p>
<p><artifactId>spring-cloud-starter-eureka-server</artifactId></dependency></p>
<ol>
<li>添加@EnableEurekaServer注解</li>
</ol>
<p>@EnableEurekaServer@SpringBootApplicationpublic class ServiceCenterApplication {}</p>
<ol>
<li>设置应用程序的端口和名称</li>
</ol>
<p>spring.application.name=service-center</p>
<p>server.port=5000</p>
<ol>
<li>启动项目，在浏览器输入<a href="http://localhost:5000/" target="_blank" rel="noopener">http://localhost:5000/</a></li>
</ol>
<p><img src="https://images.cnblogs.com/cnblogs_com/longxianghui/1083293/o_eureka.png" alt=""></p>
<h1 id="注册服务"><a href="#注册服务" class="headerlink" title="注册服务"></a>注册服务</h1><ol>
<li><p>使用vs创建一个dotnet core web api程序</p>
</li>
<li><p>使用nuget添加Pivotal.Discovery.Client库</p>
</li>
</ol>
<PackageReference Include="Pivotal.Discovery.Client" Version="1.1.0" />

<p>3.Program.cs 设置一个端口</p>
<p>public static void Main(string[] args)</p>
<p>{</p>
<p>var host = new WebHostBuilder()</p>
<p>.UseKestrel()</p>
<p>.UseContentRoot(Directory.GetCurrentDirectory())</p>
<p>.UseIISIntegration()</p>
<p>.UseStartup<Startup>()</p>
<p>.UseApplicationInsights()</p>
<p>.UseUrls(“http://*:8010”)</p>
<p>.Build();</p>
<p>host.Run();</p>
<p>}</p>
<ol>
<li>Startup.cs</li>
</ol>
<p>public void ConfigureServices(IServiceCollection services)</p>
<p>{</p>
<p>services.AddDiscoveryClient(Configuration);</p>
<p>// Add framework services.</p>
<p>services.AddMvc();</p>
<p>}</p>
<p>public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)</p>
<p>{</p>
<p>loggerFactory.AddConsole(Configuration.GetSection(“Logging”));</p>
<p>loggerFactory.AddDebug();</p>
<p>app.UseMvc();</p>
<p>app.UseDiscoveryClient();</p>
<p>}</p>
<ol>
<li>appsettings.json</li>
</ol>
<p>{</p>
<p>“Logging”: {</p>
<p>“IncludeScopes”: false,</p>
<p>“LogLevel”: {</p>
<p>“Default”: “Warning”</p>
<p>}</p>
<p>},</p>
<p>“spring”: {</p>
<p>“application”: {</p>
<p>“name”: “serviceone”</p>
<p>}</p>
<p>},</p>
<p>“eureka”: {</p>
<p>“client”: {</p>
<p>“serviceUrl”: “<a href="http://localhost:5000/eureka/" target="_blank" rel="noopener">http://localhost:5000/eureka/</a>“,</p>
<p>“shouldFetchRegistry”: false,</p>
<p>“shouldRegisterWithEureka”: true</p>
<p>},</p>
<p>“instance”: {</p>
<p>“port”: 8010</p>
<p>}</p>
<p>}</p>
<p>}</p>
<blockquote>
<p>如果是团队开发，”shouldRegisterWithEureka”设置成false，防止本地环境注册到开发环境</p>
</blockquote>
<ol>
<li>启动程序，再次访问<a href="http://localhost:5000/" target="_blank" rel="noopener">http://localhost:5000/</a>发现已经注册到服务中心了</li>
</ol>
<p><img src="https://images.cnblogs.com/cnblogs_com/longxianghui/1083293/o_eureka1.png" alt=""></p>
<ol start="2">
<li>同样的方式我们再创建一个ServiceTwo的项目，修改programe.cs和appsettings.json文件，其它不变</li>
</ol>
<p>public static void Main(string[] args)</p>
<p>{</p>
<p>var host = new WebHostBuilder()</p>
<p>.UseKestrel()</p>
<p>.UseContentRoot(Directory.GetCurrentDirectory())</p>
<p>.UseIISIntegration()</p>
<p>.UseStartup<Startup>()</p>
<p>.UseApplicationInsights()</p>
<p>.UseUrls(“http://*:8011”)</p>
<p>.Build();</p>
<p>host.Run();</p>
<p>{</p>
<p>“Logging”: {</p>
<p>“IncludeScopes”: false,</p>
<p>“LogLevel”: {</p>
<p>“Default”: “Warning”</p>
<p>}</p>
<p>},</p>
<p>“spring”: {</p>
<p>“application”: {</p>
<p>“name”: “servicetwo”</p>
<p>}</p>
<p>},</p>
<p>“eureka”: {</p>
<p>“client”: {</p>
<p>“serviceUrl”: “<a href="http://loclhost:5000/eureka/" target="_blank" rel="noopener">http://loclhost:5000/eureka/</a>“,</p>
<p>“shouldFetchRegistry”: false,</p>
<p>“shouldRegisterWithEureka”: true</p>
<p>},</p>
<p>“instance”: {</p>
<p>“port”: 8011</p>
<p>}</p>
<p>}</p>
<p>}</p>
<ol>
<li>再次访问<a href="http://localhost:5000/" target="_blank" rel="noopener">http://localhost:5000/</a>，发现ServiceOne和ServiceTwo都已经注册到服务中心了</li>
</ol>
<p><img src="https://images.cnblogs.com/cnblogs_com/longxianghui/1083293/o_eureka2.png" alt=""></p>
<h1 id="后记"><a href="#后记" class="headerlink" title="后记"></a>后记</h1><p>这样一个简单的服务治理平台就搭建出来了,我们通过spring cloud来创建了一个服务中心,然后通过dotnet core创建了2个服务注册到了服务中心,但是这些离微服务还差的远.服务之间怎么相互调用呢?集群模式怎么处理呢?微服务的统一API网关呢？留下这些问题，且听下回分解。</p>
<p>第二篇文章已经发布。<a href="http://www.cnblogs.com/longxianghui/p/7576736.html" target="_blank" rel="noopener">spring cloud+dotnet core搭建微服务架构：服务发现（二）</a></p>
<h1 id="示例代码"><a href="#示例代码" class="headerlink" title="示例代码"></a>示例代码</h1><p>所有代码均上传<a href="https://github.com/longxianghui/microservice" target="_blank" rel="noopener">github</a>。代码按照章节的顺序上传，例如第一章demo1，第二章demo2以此类推。</p>
<p>求推荐，你们的支持是我写作最大的动力，我的QQ群：328438252,交流微服务。</p>
<h1 id="传送门"><a href="#传送门" class="headerlink" title="传送门"></a>传送门</h1><ul>
<li><p><a href="http://www.cnblogs.com/longxianghui/p/7561259.html" target="_blank" rel="noopener">spring cloud+dotnet core搭建微服务架构：服务注册（一）</a></p>
</li>
<li><p><a href="http://www.cnblogs.com/longxianghui/p/7576736.html" target="_blank" rel="noopener">spring cloud+dotnet core搭建微服务架构：服务发现（二）</a></p>
</li>
<li><p><a href="http://www.cnblogs.com/longxianghui/p/7646870.html" target="_blank" rel="noopener">spring cloud+dotnet core搭建微服务架构： Api网关（三）</a></p>
</li>
<li><p><a href="http://www.cnblogs.com/longxianghui/p/7660752.html" target="_blank" rel="noopener">spring cloud+dotnet core搭建微服务架构：配置中心（四）</a></p>
</li>
</ul>
<h1 id="参考资料"><a href="#参考资料" class="headerlink" title="参考资料"></a>参考资料</h1><p>java部分</p>
<ul>
<li><p><a href="https://github.com/SpringCloud/spring-cloud-docs" target="_blank" rel="noopener">spring cloud文档</a></p>
</li>
<li><p><a href="http://www.cnblogs.com/ityouknow/category/994104.html" target="_blank" rel="noopener">纯洁大神spring cloud系列</a></p>
</li>
</ul>
<p>.net部分</p>
<ul>
<li><p><a href="http://steeltoe.io/docs/" target="_blank" rel="noopener">SteeltoeOSS文档</a></p>
</li>
<li><p><a href="https://github.com/SteeltoeOSS/" target="_blank" rel="noopener">SteeltoeOSS源码</a></p>
</li>
</ul>

  </div>
</article>



        
          <div id="footer-post-container">
  <div id="footer-post">

    <div id="nav-footer" style="display: none">
      <ul>
         
          <li><a href="/">Home</a></li>
         
          <li><a href="/about/">About</a></li>
         
          <li><a href="/archives/">Writing</a></li>
         
          <li><a href="/projects_url">Projects</a></li>
        
      </ul>
    </div>

    <div id="toc-footer" style="display: none">
      <ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#spring-cloud-net-core搭建微服务架构：服务注册（一）"><span class="toc-number">1.</span> <span class="toc-text">spring cloud+.net core搭建微服务架构：服务注册（一）</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#背景"><span class="toc-number">2.</span> <span class="toc-text">背景</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#spring-cloud"><span class="toc-number">3.</span> <span class="toc-text">spring cloud</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#服务治理"><span class="toc-number">4.</span> <span class="toc-text">服务治理</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#搭建服务治理平台"><span class="toc-number">5.</span> <span class="toc-text">搭建服务治理平台</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#注册服务"><span class="toc-number">6.</span> <span class="toc-text">注册服务</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#后记"><span class="toc-number">7.</span> <span class="toc-text">后记</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#示例代码"><span class="toc-number">8.</span> <span class="toc-text">示例代码</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#传送门"><span class="toc-number">9.</span> <span class="toc-text">传送门</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#参考资料"><span class="toc-number">10.</span> <span class="toc-text">参考资料</span></a></li></ol>
    </div>

    <div id="share-footer" style="display: none">
      <ul>
  <li><a class="icon" href="http://www.facebook.com/sharer.php?u=http://yoursite.com/2018/11/04/springcloud+steeltoe%E5%AE%9E%E7%8E%B0%E5%BE%AE%E6%9C%8D%E5%8A%A1%E6%9E%B6%E6%9E%84%EF%BC%9A%E6%9C%8D%E5%8A%A1%E6%B3%A8%E5%86%8C%EF%BC%88%E4%B8%80%EF%BC%89/" target="_blank" rel="noopener"><i class="fab fa-facebook fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" href="https://twitter.com/share?url=http://yoursite.com/2018/11/04/springcloud+steeltoe%E5%AE%9E%E7%8E%B0%E5%BE%AE%E6%9C%8D%E5%8A%A1%E6%9E%B6%E6%9E%84%EF%BC%9A%E6%9C%8D%E5%8A%A1%E6%B3%A8%E5%86%8C%EF%BC%88%E4%B8%80%EF%BC%89/&text=springcloud+steeltoe实现微服务架构：服务注册（一）" target="_blank" rel="noopener"><i class="fab fa-twitter fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" href="http://www.linkedin.com/shareArticle?url=http://yoursite.com/2018/11/04/springcloud+steeltoe%E5%AE%9E%E7%8E%B0%E5%BE%AE%E6%9C%8D%E5%8A%A1%E6%9E%B6%E6%9E%84%EF%BC%9A%E6%9C%8D%E5%8A%A1%E6%B3%A8%E5%86%8C%EF%BC%88%E4%B8%80%EF%BC%89/&title=springcloud+steeltoe实现微服务架构：服务注册（一）" target="_blank" rel="noopener"><i class="fab fa-linkedin fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" href="https://pinterest.com/pin/create/bookmarklet/?url=http://yoursite.com/2018/11/04/springcloud+steeltoe%E5%AE%9E%E7%8E%B0%E5%BE%AE%E6%9C%8D%E5%8A%A1%E6%9E%B6%E6%9E%84%EF%BC%9A%E6%9C%8D%E5%8A%A1%E6%B3%A8%E5%86%8C%EF%BC%88%E4%B8%80%EF%BC%89/&is_video=false&description=springcloud+steeltoe实现微服务架构：服务注册（一）" target="_blank" rel="noopener"><i class="fab fa-pinterest fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" href="mailto:?subject=springcloud+steeltoe实现微服务架构：服务注册（一）&body=Check out this article: http://yoursite.com/2018/11/04/springcloud+steeltoe%E5%AE%9E%E7%8E%B0%E5%BE%AE%E6%9C%8D%E5%8A%A1%E6%9E%B6%E6%9E%84%EF%BC%9A%E6%9C%8D%E5%8A%A1%E6%B3%A8%E5%86%8C%EF%BC%88%E4%B8%80%EF%BC%89/"><i class="fas fa-envelope fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" href="https://getpocket.com/save?url=http://yoursite.com/2018/11/04/springcloud+steeltoe%E5%AE%9E%E7%8E%B0%E5%BE%AE%E6%9C%8D%E5%8A%A1%E6%9E%B6%E6%9E%84%EF%BC%9A%E6%9C%8D%E5%8A%A1%E6%B3%A8%E5%86%8C%EF%BC%88%E4%B8%80%EF%BC%89/&title=springcloud+steeltoe实现微服务架构：服务注册（一）" target="_blank" rel="noopener"><i class="fab fa-get-pocket fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" href="http://reddit.com/submit?url=http://yoursite.com/2018/11/04/springcloud+steeltoe%E5%AE%9E%E7%8E%B0%E5%BE%AE%E6%9C%8D%E5%8A%A1%E6%9E%B6%E6%9E%84%EF%BC%9A%E6%9C%8D%E5%8A%A1%E6%B3%A8%E5%86%8C%EF%BC%88%E4%B8%80%EF%BC%89/&title=springcloud+steeltoe实现微服务架构：服务注册（一）" target="_blank" rel="noopener"><i class="fab fa-reddit fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" href="http://www.stumbleupon.com/submit?url=http://yoursite.com/2018/11/04/springcloud+steeltoe%E5%AE%9E%E7%8E%B0%E5%BE%AE%E6%9C%8D%E5%8A%A1%E6%9E%B6%E6%9E%84%EF%BC%9A%E6%9C%8D%E5%8A%A1%E6%B3%A8%E5%86%8C%EF%BC%88%E4%B8%80%EF%BC%89/&title=springcloud+steeltoe实现微服务架构：服务注册（一）" target="_blank" rel="noopener"><i class="fab fa-stumbleupon fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" href="http://digg.com/submit?url=http://yoursite.com/2018/11/04/springcloud+steeltoe%E5%AE%9E%E7%8E%B0%E5%BE%AE%E6%9C%8D%E5%8A%A1%E6%9E%B6%E6%9E%84%EF%BC%9A%E6%9C%8D%E5%8A%A1%E6%B3%A8%E5%86%8C%EF%BC%88%E4%B8%80%EF%BC%89/&title=springcloud+steeltoe实现微服务架构：服务注册（一）" target="_blank" rel="noopener"><i class="fab fa-digg fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" href="http://www.tumblr.com/share/link?url=http://yoursite.com/2018/11/04/springcloud+steeltoe%E5%AE%9E%E7%8E%B0%E5%BE%AE%E6%9C%8D%E5%8A%A1%E6%9E%B6%E6%9E%84%EF%BC%9A%E6%9C%8D%E5%8A%A1%E6%B3%A8%E5%86%8C%EF%BC%88%E4%B8%80%EF%BC%89/&name=springcloud+steeltoe实现微服务架构：服务注册（一）&description=" target="_blank" rel="noopener"><i class="fab fa-tumblr fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" href="https://news.ycombinator.com/submitlink?u=http://yoursite.com/2018/11/04/springcloud+steeltoe%E5%AE%9E%E7%8E%B0%E5%BE%AE%E6%9C%8D%E5%8A%A1%E6%9E%B6%E6%9E%84%EF%BC%9A%E6%9C%8D%E5%8A%A1%E6%B3%A8%E5%86%8C%EF%BC%88%E4%B8%80%EF%BC%89/&t=springcloud+steeltoe实现微服务架构：服务注册（一）" target="_blank" rel="noopener"><i class="fab fa-hacker-news fa-lg" aria-hidden="true"></i></a></li>
</ul>

    </div>

    <div id="actions-footer">
        <a id="menu" class="icon" href="#" onclick="$('#nav-footer').toggle();return false;"><i class="fas fa-bars fa-lg" aria-hidden="true"></i> Menu</a>
        <a id="toc" class="icon" href="#" onclick="$('#toc-footer').toggle();return false;"><i class="fas fa-list fa-lg" aria-hidden="true"></i> TOC</a>
        <a id="share" class="icon" href="#" onclick="$('#share-footer').toggle();return false;"><i class="fas fa-share-alt fa-lg" aria-hidden="true"></i> Share</a>
        <a id="top" style="display:none" class="icon" href="#" onclick="$('html, body').animate({ scrollTop: 0 }, 'fast');"><i class="fas fa-chevron-up fa-lg" aria-hidden="true"></i> Top</a>
    </div>

  </div>
</div>

        
        <footer id="footer">
  <div class="footer-left">
    Copyright &copy; 2020 Tmoonlight
  </div>
  <div class="footer-right">
    <nav>
      <ul>
         
          <li><a href="/">Home</a></li>
         
          <li><a href="/about/">About</a></li>
         
          <li><a href="/archives/">Writing</a></li>
         
          <li><a href="/projects_url">Projects</a></li>
        
      </ul>
    </nav>
  </div>
</footer>

    </div>
    <!-- styles -->

<link rel="stylesheet" href="/lib/font-awesome/css/all.min.css">


<link rel="stylesheet" href="/lib/justified-gallery/css/justifiedGallery.min.css">


    <!-- jquery -->

<script src="/lib/jquery/jquery.min.js"></script>


<script src="/lib/justified-gallery/js/jquery.justifiedGallery.min.js"></script>

<!-- clipboard -->

  
<script src="/lib/clipboard/clipboard.min.js"></script>

  <script type="text/javascript">
  $(function() {
    // copy-btn HTML
    var btn = "<span class=\"btn-copy tooltipped tooltipped-sw\" aria-label=\"Copy to clipboard!\">";
    btn += '<i class="far fa-clone"></i>';
    btn += '</span>'; 
    // mount it!
    $(".highlight table").before(btn);
    var clip = new ClipboardJS('.btn-copy', {
      text: function(trigger) {
        return Array.from(trigger.nextElementSibling.querySelectorAll('.code')).reduce((str,it)=>str+it.innerText+'\n','')
      }
    });
    clip.on('success', function(e) {
      e.trigger.setAttribute('aria-label', "Copied!");
      e.clearSelection();
    })
  })
  </script>


<script src="/js/main.js"></script>

<!-- search -->

<!-- Google Analytics -->

<!-- Baidu Analytics -->

<!-- Disqus Comments -->


</body>
</html>
